
package com.jc.platform.zhaomeng.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jc.platform.zhaomeng.entity.RPartnerPurchaseContractEntity;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * ClassName RPartnerPurchaseContractMapper.java
 * Description 【Partner】 与 【PurchaseContract】 中间表Mapper
 *
 * @author zhaomeng
 * @version 2.0
 * @date 2021/08/07
 */
@Mapper
public interface IRPartnerPurchaseContractMapper extends BaseMapper<RPartnerPurchaseContractEntity>
{
    /***
     * 根据实体1 Id 删除对应的关联数据
     *
     * @param id
     */
    @Delete("delete from r_partner_purchase_contract where partner_id = #{id}")
    void deleteByPartnerId(Long id);

    /***
     * 根据实体2 Id 删除对应的关联数据
     *
     * @param id
     */
    @Delete("delete from r_partner_purchase_contract where contract_id = #{id}")
    void deleteByContractId(Long id);

    /**
     * 根据实体1 ID 获取 实体2 ID集合
     *
     * @param id 实体ID
     * @return ids 另一实体ID集合
     */
    @Select("select partner_id from r_partner_purchase_contract where contract_id = #{id}")
    List<Long> findPartnerIdByContractId(Long id);

    /**
     * 根据实体2 ID 获取 实体1 ID集合
     *
     * @param id 实体ID
     * @return ids 另一实体ID集合
     */
    @Select("select contract_id from r_partner_purchase_contract where partner_id = #{id}")
    List<Long> findContractIdByPartnerId(Long id);

}
